import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
const publicKey = '#公钥'

// 动图类型验证正则表达式
export const regexPhoto = /^(image\/)(gif|swf)$/
// 图片验证正则表达式
export const regexImage = /^(image\/)(png|jpeg|tiff|raw|bmp|jpg|pdf)$/
// 视频格式验证正则表达式
export const regexVideo = /^(video\/)(mp4|avi|mov|mkv|flv|rmvb|mvb)$/
// 图片或者视频格式正则表达式
export const regexImageOrVideo = /^(image\/)(png|jpeg|tiff|raw|bmp|jpg|pdf)|(video\/)(mp4|avi|mov|mkv|flv|rmvb|mvb)$/
// 文件下载前缀 dev
export const downloadUrl = 'http://localhost:12001/attachment/download?attachNo='
// 文件安全下载前缀
export const secureDownloadUrl = 'http://localhost:12001/attachment/secureDownload?attachNo='

// 数据加密
export function encrypt (txt) {
  const encryptor = new JSEncrypt()

  encryptor.setPublicKey(publicKey) // 设置公钥

  return encryptor.encrypt(txt) // 对需要加密的数据进行加密
}
